<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />





  <link rel="alternate" href="/atom.xml" title="yampery" type="application/atom+xml" />






<meta name="description" content="基础镜像 elkbase:v1.0 准备jdk 放在tools文件夹下 准备Dockerfile FROM centos:latest MAINTAINER Yampery&amp;lt;yampery@163.com&amp;gt; VOLUME [ &amp;quot;/opt/product/data/&amp;quot; ] RUN  /bin/cp /usr/share/zoneinfo/Asia/Shanghai /">
<meta property="og:type" content="article">
<meta property="og:title" content="基于docker搭建ELK系统">
<meta property="og:url" content="https://yampery.gitee.io/2019/02/25/docker_elk/index.html">
<meta property="og:site_name" content="yampery">
<meta property="og:description" content="基础镜像 elkbase:v1.0 准备jdk 放在tools文件夹下 准备Dockerfile FROM centos:latest MAINTAINER Yampery&amp;lt;yampery@163.com&amp;gt; VOLUME [ &amp;quot;/opt/product/data/&amp;quot; ] RUN  /bin/cp /usr/share/zoneinfo/Asia/Shanghai /">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-05-18T08:22:55.267Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="基于docker搭建ELK系统">
<meta name="twitter:description" content="基础镜像 elkbase:v1.0 准备jdk 放在tools文件夹下 准备Dockerfile FROM centos:latest MAINTAINER Yampery&amp;lt;yampery@163.com&amp;gt; VOLUME [ &amp;quot;/opt/product/data/&amp;quot; ] RUN  /bin/cp /usr/share/zoneinfo/Asia/Shanghai /">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://yampery.gitee.io/2019/02/25/docker_elk/"/>





  <title>基于docker搭建ELK系统 | yampery</title>
  








  <link href='//fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">yampery</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">天尽头，回眸望红尘</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://yampery.gitee.io/2019/02/25/docker_elk/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="yampery">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="yampery">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">基于docker搭建ELK系统</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-02-25T11:05:38+08:00">
                2019-02-25
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2019/02/25/docker_elk/" class="leancloud_visitors" data-flag-title="基于docker搭建ELK系统">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.3k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  7 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="基础镜像-elkbase-v1-0"><a href="#基础镜像-elkbase-v1-0" class="headerlink" title="基础镜像 elkbase:v1.0"></a>基础镜像 elkbase:v1.0</h2><ul>
<li>准备jdk 放在tools文件夹下</li>
<li><p>准备Dockerfile</p>
<pre><code>FROM centos:latest
MAINTAINER Yampery&lt;yampery@163.com&gt;
VOLUME [ &quot;/opt/product/data/&quot; ]
RUN  /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN /bin/echo -e &quot;ZONE=&quot;Asia/Shanghai&quot;\nUTC=false\nRTC=false&quot; &gt; /etc/sysconfig/clock
RUN mkdir /opt/product/tools/
ADD ./tools /opt/product/tools/
ENV JAVA_HOME /opt/product/tools/jdk-9.0.1
CMD [&quot;/usr/sbin/init&quot;]
</code></pre></li>
<li><p>构建文件结构</p>
<pre><code>|-elk
    |-tools
        |-jdk-9.0.1
    |--Dockerfile
</code></pre></li>
<li><p>构建镜像</p>
<pre><code>elk/elkbase$ docker build -t elkbase:v1.0 . 
</code></pre></li>
</ul>
<h2 id="elasticsearch-v1-0"><a href="#elasticsearch-v1-0" class="headerlink" title="elasticsearch:v1.0"></a>elasticsearch:v1.0</h2><ul>
<li><p>准备elasticsearch</p>
<pre><code>https://www.elastic.co/downloads/elasticsearch
</code></pre></li>
<li><p>准备Dockerfile</p>
<pre><code>FROM elkbase:v1.0
MAINTAINER Yampery&lt;yampery@163.com&gt;
VOLUME [ &quot;/opt/product/data/&quot; ]
ADD ./tools /opt/product/
RUN useradd elk &amp;&amp; chown -R elk:elk /opt/product/elasticsearch-6.0.0
ADD build.sh /root/
RUN chmod +x /root/build.sh
EXPOSE 9200
EXPOSE 9300
ENTRYPOINT [&quot;/root/build.sh&quot;]
CMD [&quot;/usr/sbin/init&quot;]
</code></pre></li>
<li><p>准备脚本build.sh</p>
<pre><code>#!/bin/bash
echo &quot;* soft nofile 65536&quot; &gt; /etc/security/limits.conf 
echo &quot;* hard nofile 131072&quot; &gt; /etc/security/limits.conf
echo &quot;* soft nproc 2048&quot; &gt; /etc/security/limits.conf
echo &quot;* hard nproc 4096&quot; &gt; /etc/security/limits.conf
echo &quot;vm.max_map_count=655360&quot; &gt; /etc/sysctl.conf 
sysctl -p
cd /opt/product/elasticsearch-6.0.0/config/
rm -rf elasticsearch.yml
cp /opt/product/data/elk/elasticsearch.yml .
chown -R elk:elk /opt/product/elasticsearch-6.0.0
chown -R elk:elk /opt/product/data/elk/elasticsearchdata
su - elk &lt;&lt;!
export JAVA_HOME=/opt/product/tools/jdk-9.0.1
export PATH=$JAVA_HOME/bin:$PATH 
/opt/product/elasticsearch-6.0.0/bin/elasticsearch
</code></pre></li>
<li><p>构建目录结构</p>
<pre><code>|-elk
    |-elasticsearch
        |-tools
        |--Dockerfile
        |--build.sh
</code></pre></li>
<li><p>构建镜像</p>
<pre><code>elk/elasticsearch$ docker build -f elasticsearch:v1.0 .
</code></pre></li>
<li><p>配置</p>
<pre><code>在/opt/product/data目录下建立elk目录，并拷贝elasticsearch.yml文件到该目录
path.data: /opt/product/data/elk/elasticsearchdata
network.host: 0.0.0.0
在/opt/product/data/elk目录 创建 elasticsearchdata 目录
</code></pre></li>
<li><p>运行容器 </p>
<pre><code>docker run --name elasticsearch --privileged --restart=always -d -ti -v /opt/product/data:/opt/product/data -p 9200:9200 -p 9300:9300 elasticsearch:v1.0 /bin/bash
</code></pre><p>  -&gt; 访问：ip:9200/</p>
</li>
</ul>
<h2 id="logstash"><a href="#logstash" class="headerlink" title="logstash"></a>logstash</h2><hr>
<ul>
<li><p>准备logstash    </p>
<pre><code>https://www.elastic.co/downloads/logstash    
</code></pre></li>
<li><p>准备Dockerfile</p>
<pre><code>FROM elkbase:v1.0
MAINTAINER Yampery&lt;yampery@163.com&gt;
VOLUME [ &quot;/opt/product/data/&quot; ]
ADD ./tools /opt/product/
ADD build.sh /root/
RUN chmod +x /root/build.sh
EXPOSE 5044
EXPOSE 4560
EXPOSE 8080
ENTRYPOINT [&quot;/root/build.sh&quot;]
CMD [&quot;/usr/sbin/init&quot;]
</code></pre></li>
<li><p>准备脚本 build.sh</p>
<pre><code>#!/bin/bash
export JAVA_HOME=/opt/product/tools/jdk-9.0.1
export PATH=$JAVA_HOME/bin:$PATH
JAVA_OPTS=&quot;$JAVA_OPTS -Dfile.encoding=UTF8  -Duser.timezone=GMT+08&quot;
cd /opt/product/logstash-6.0.0/config/
rm -rf logstash.yml
cp /opt/product/data/elk/logstash.yml logstash.yml
/opt/product/logstash-6.0.0/bin/logstash -f /opt/product/data/elk/logstash.conf
</code></pre></li>
<li><p>目录结构</p>
<pre><code>|-elk
    |-logstash
        |-tools
        |--Dockerfile
        |--build.sh
</code></pre></li>
<li><p>构建镜像</p>
<pre><code>elk/logstash$ docker build -f logstash:v1.0 .
</code></pre></li>
<li><p>配置logstash</p>
<pre><code>// 在/opt/product/data/elk目录下创建logstash.conf
input {     
   beats {
    port =&gt; &quot;5044&quot;
   }
}
output {
   elasticsearch {
       hosts =&gt; [&quot;elasticsearch的ip:9200&quot;]
       index =&gt; &quot;logstash-tomcat-accesslog-%{+YYYY.MM.dd}&quot;
    }       
}
// 将logstash本身的logstash.yml 拷贝到/opt/product/data/elk目录下
// 在/opt/product/data/elk目录下建立 logstashdata目录
</code></pre></li>
<li><p>启动</p>
<pre><code>docker run --name logstash --restart=always -d -ti -v /opt/product/data:/opt/product/data -p 5044:5044 -p 4560:4560 -p 9090:9090 logstash:v1.0 /bin/bash
</code></pre></li>
</ul>
<h2 id="kibana"><a href="#kibana" class="headerlink" title="kibana"></a>kibana</h2><hr>
<ul>
<li><p>准备kibana </p>
<pre><code>https://artifacts.elastic.co/downloads/kibana/kibana-6.0.0-linux-x86_64.tar.gz
</code></pre></li>
<li><p>准备Dockerfile</p>
<pre><code>FROM elkbase:v1.0
MAINTAINER Yampery&lt;yampery@163.com&gt;
VOLUME [ &quot;/opt/product/data/&quot; ]
ADD ./tools /opt/product/
ADD build.sh /root/
RUN chmod +x /root/build.sh
EXPOSE 5601
ENTRYPOINT [&quot;/root/build.sh&quot;]
CMD [&quot;/usr/sbin/init&quot;]
</code></pre></li>
<li><p>准备脚本 build.sh</p>
<pre><code>#!/bin/bash 
export JAVA_HOME=/opt/product/tools/jdk-9.0.1
export PATH=$JAVA_HOME/bin:$PATH
cd /opt/product/kibana-6.0.0/config/
rm -rf kibana.yml
ln -s /opt/product/data/elk/kibana.yml . 
cd /opt/product/kibana-6.0.0/
rm -rf data
ln -s  /opt/product/data/elk/kibanadata /opt/product/kibana-6.0.0/data
/opt/product/kibana-6.0.0/bin/kibana
</code></pre></li>
<li><p>构建镜像</p>
<pre><code>elk/kibana$ docker build -t kibana:v1.0 .
</code></pre></li>
<li><p>配置kibana</p>
<pre><code>// 复制kibana.yml到/opt/product/data/elk 下
server.port: 5601
server.host: &quot;0.0.0.0&quot;
elasticsearch.url: &quot;http://ip:9200&quot;
</code></pre></li>
<li><p>启动</p>
<pre><code>docker run --name kibana -d -ti -v /opt/product/data:/opt/product/data -p 5601:5601  kibana:v1.0 /bin/bash
</code></pre></li>
<li><p>访问</p>
<pre><code>ip:5601/
</code></pre></li>
</ul>
<h2 id="FileBeat"><a href="#FileBeat" class="headerlink" title="FileBeat"></a>FileBeat</h2><hr>
<ul>
<li><p>准备FileBeat</p>
<pre><code>https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.0.0-linux-x86_64.tar.gz
</code></pre></li>
<li><p>准备Dockerfile</p>
<pre><code>FROM elkbase:v1.0
MAINTAINER Yampery&lt;yampery@163.com&gt;
VOLUME [ &quot;/opt/product/data/&quot; ]
ADD ./tools /opt/product/
ADD build.sh /root/
RUN chmod +x /root/build.sh
ENTRYPOINT [&quot;/root/build.sh&quot;]
CMD [&quot;/usr/sbin/init&quot;]
</code></pre></li>
<li><p>准备脚本 build.sh</p>
<pre><code>#!/bin/bash
export JAVA_HOME=/opt/product/tools/jdk-9.0.1
export PATH=$JAVA_HOME/bin:$PATH
cd /opt/product/filebeat-6.0.0/
rm -rf filebeat.yml
ln -s /opt/product/data/elk/filebeat.yml . 
rm -rf data 
ln -s /opt/product/data/elk/filebeatdata /opt/product/filebeat-6.0.0/data
/opt/product/filebeat-6.0.0/filebeat -e -c filebeat.yml
</code></pre></li>
<li><p>构建镜像</p>
<pre><code>elk/filebeat$ docker build -t filebeat:v1.0 .
</code></pre></li>
<li><p>配置filebeat</p>
<pre><code>// 在/opt/product/data/elk目录下 创建filebeat.yml
filebeat.prospectors:
  - input_type: log
    document_type: tomcataccess
  paths:
     - /opt/product/data/logs/tomcat/localhost_access_log*.txt
     - /opt/product/data/epg2logs/tomcat/localhost_access_log*.txt
output.logstash:
  // The Logstash hosts
  hosts: [&quot;ip:5044&quot;]

 // 在/opt/product/data/elk 目录下创建filebeatdata
</code></pre></li>
</ul>
<ul>
<li><p>启动</p>
<pre><code>docker run --name filebeat -d -ti -v /opt/product/data:/opt/product/data filebeat:v1.0 /bin/bash
</code></pre></li>
</ul>
<h2 id="x-pack"><a href="#x-pack" class="headerlink" title="x-pack"></a>x-pack</h2><ul>
<li><p>安装    </p>
<pre><code>./elasticsearch-plugin install x-pack
</code></pre></li>
<li><p>设置密码 </p>
</li>
</ul>
<p><a href="https://www.elastic.co/guide/en/x-pack/current/setting-up-authentication.html#set-built-in-user-passwords" title="es官网参考" target="_blank" rel="noopener">https://www.elastic.co/guide/en/x-pack/current/setting-up-authentication.html#set-built-in-user-passwords</a></p>
<pre><code>./setup-passwords interactive
    Enter password for [elastic]:
    Reenter password for [elastic]:
    Enter password for [kibana]:
    Reenter password for [kibana]:
    Enter password for [logstash_system]:
    Reenter password for [logstash_system]:
    Changed password for user [kibana]
    Changed password for user [logstash_system]
    Changed password for user [elastic]
</code></pre><ul>
<li><p>logstash配置</p>
<pre><code>input { stdin { } }
output {
  elasticsearch {
    hosts =&gt; [&quot;192.168.107.23:9200&quot;]
    user =&gt; elastic
    password =&gt; elastic
  }
  stdout { codec =&gt; rubydebug }
}
</code></pre><p><em>同理，kibana也可以配置，调用es接口也需要用户密码</em></p>
</li>
</ul>
<h2 id="说明"><a href="#说明" class="headerlink" title="说明"></a>说明</h2><hr>
<p><em>脚本和启动项参数中的/opt/product/data均以自己要设定的挂载目录一致</em></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/02/25/distcp/" rel="next" title="Hadoop集群间文件拷贝">
                <i class="fa fa-chevron-left"></i> Hadoop集群间文件拷贝
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/02/25/ykt_test_binding/" rel="prev" title="性能测试">
                性能测试 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">yampery</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/yampery" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:1yampery@gmail.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#基础镜像-elkbase-v1-0"><span class="nav-number">1.</span> <span class="nav-text">基础镜像 elkbase:v1.0</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#elasticsearch-v1-0"><span class="nav-number">2.</span> <span class="nav-text">elasticsearch:v1.0</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#logstash"><span class="nav-number">3.</span> <span class="nav-text">logstash</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#kibana"><span class="nav-number">4.</span> <span class="nav-text">kibana</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#FileBeat"><span class="nav-number">5.</span> <span class="nav-text">FileBeat</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#x-pack"><span class="nav-number">6.</span> <span class="nav-text">x-pack</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#说明"><span class="nav-number">7.</span> <span class="nav-text">说明</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2018 &mdash; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yampery</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io" rel="external nofollow">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next" rel="external nofollow">NexT.Mist</a> v5.1.4</div>




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i> 本站访客数
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i> 本站总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("35rGUMRzp5wPN2jmmIUWeBNh-gzGzoHsz", "fmF6mJDmgl0FkqBKX8I2HiGF");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  

  

  

  

</body>
</html>
